﻿using SaaS.Model.Dto.Users;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using XCore.Domain.Entities;

namespace SaaS.Model.Entity.Users
{
    [Table("Users")]
    public class User : IEntity<int>, IHasCreationTime, IHasCreateionIpAddress
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        [Column("UserId")]
        public int Id { get; set; }
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }
        /// <summary>
        /// 注册IP
        /// </summary>
        public string IP { get; set; }
        /// <summary>
        /// 注册时间
        /// </summary>
        public DateTime CreationTime { get; set; }


        public static implicit operator UserModel(User user)
        {
            return new UserModel
            {
                Id = user.Id,
                UserName = user.UserName,
                CreationTime = user.CreationTime,
            };
        }
    }
}
